<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="/common/upLoadFile" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="提交">
</form>

<input id="file" type="file" name="file">
<input id="sbt" type="submit" value="提交">
</body>
<script type="text/javascript" src="../assets/js/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../assets/js/common.js"></script>
<script type="text/javascript" src="../assets/js/main.js"></script>
<script>
    $(function () {

        var data = {
            username: "用户账号名",
            password: "用户密码 密文"
        };
       ajax.post("/system/query",data);
        // $.ajax({
        //     url: "/system/query",
        //     type: 'POST',
        //     data: inout.getParam(data),
        //     contentType: "application/json",
        //     success: function (data) {
        //         console.log(inout.getData(data));
        //         var i = {};
        //         inout.doList(data, i);
        //         console.log(i);
        //     }
        // });
        // $.post("/system/query", param, function (data) {
        //     getData(data);
        // });

        $("#sbt").click(function () {
            var formData = new FormData();
            if ($("#file")[0].files[0] == null) {
                alert("无文件");
                return;
            }
            formData.append("file", $("#file")[0].files[0]);
            $.ajax({
                url: "/common/upLoadFile",
                type: 'POST',
                data: formData,
                contentType: false, //不指定提交数据类型
                processData: false, //提交数据不做处理
                success: function (data) {
                    console.log(data);
                    var result = JSON.parse(data);
                    // 判断逻辑
                }
            });
        });

        $("#login").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            var param = {
                username: username,
                password: password
            };
            $.post("<%=path%>/LoginServlet", param, function (data) {
                inout.getData(data);
            });
        });
    });
</script>
</html>